package features.advance.jdk.io.mina;

import org.springframework.scheduling.concurrent.CustomizableThreadFactory;

import java.util.ArrayList;
import java.util.Collection;
import java.util.concurrent.*;

/**
 * @author LIN
 * @date 2021-07-12
 */
public class Demo {

    public static void main(String[] args) throws InterruptedException {
        ThreadFactory springThreadFactory = new CustomizableThreadFactory("springThread-pool-");

        ExecutorService executorService = new ThreadPoolExecutor(0, Integer.MAX_VALUE,
                60L, TimeUnit.SECONDS,
                new SynchronousQueue<Runnable>(),
                springThreadFactory
        );
//        Future<?> submit = executorService.submit(() -> System.out.println(12));
        Collection<Callable<Object>> list = new ArrayList<>();
        list.add(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                System.out.println(Thread.currentThread().getName());
                return null;
            }
        });
        list.add(new Callable<Object>() {
            @Override
            public Object call() throws Exception {
                System.out.println(Thread.currentThread().getName());
                return null;
            }
        });
        executorService.invokeAll(list);
        executorService.shutdown();

    }

    public void test(){
        System.out.println("test");
    }

}
